#@layout()

#define css()
<link rel="stylesheet" href="#(CPATH)/static/components/jquery-file-upload/css/jquery.fileupload.css">
<style>
    #uploader {
        height: 230px;
    }

    .myPanel {
        font-size: 25px;
        color: #ccc;
        text-align: center;
        padding-top: 60px;
    }

</style>
#end

#define script()
<script src="#(CPATH)/static/components/jquery-file-upload/js/vendor/jquery.ui.widget.js"></script>
<script src="#(CPATH)/static/components/jquery-file-upload/js/jquery.iframe-transport.js"></script>
<script src="#(CPATH)/static/components/jquery-file-upload/js/jquery.fileupload.js"></script>
<script>
    $('#cfile').fileupload({
        dropZone: $('#uploader'),
        url: '#(CPATH)/admin/addon/doUploadAndUpgrade?id=#(addon.id)',
        sequentialUploads: true,
        progressall: function (e, data) {
            var progress = parseInt(data.loaded / data.total * 100, 10);
            $(".myPanel").text("上传进度：" + progress + "%")
        },
        done: function (e, data) {

            $(".myPanel").html("或者将新的#(addon.title ??)插件文件<br />拖动到这里进行安装...");

            if (data.result.state == "ok") {
                toastr.options.onHidden = function () {
                    location.href = "#(CPATH)/admin/addon";
                }
                toastr.success(" 插件升级成功，请启动该插件 ")
            } else {
                toastr.error(data.result.message)
            }
        }
    });
</script>
#end

#define content()

    <section class="content-header">
        <h1>
            插件升级
            <small>Addon Upgrade</small>
        </h1>
    </section>

    <section class="content">

        <div class="container-fluid">
                <div class="card card-outline card-primary">
                    <div class="card-body">
                        <div id="uploader">
                            <span class="btn btn-block btn-primary fileinput-button" style="width: 180px">
                                <i class="fas fa-plus"></i>
                                <span>选择新的插件文件...</span>
                                <input id="cfile" type="file" name="files[]" multiple>
                            </span>

                            <div class="myPanel">
                                或者将新的#(addon.title ??)插件文件<br />拖动到这里进行安装...
                            </div>
                        </div>
                    </div>
                </div>
            </div>

    </section>

#end
